package si.yun.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import si.yun.service.SyTeacherSystemService;
import si.yun.utils.JsonData;

import java.text.ParseException;
import java.util.Map;

/**
 * @ClassName: 教师首页WEB层
 * @Description: TODO
 * @Author: 柴秋生
 * @Date 2021/9/11 11:33
 */
@Controller
@RequestMapping("/teacherSystem")
public class SyTeacherSystemController {
    @Autowired
    private SyTeacherSystemService syTeacherSystemService;
    /**
     * 首页——上传的视频浏览数
     * @Author : 柴秋生
     * @Date : 2021/8/2 19:04
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @RequestMapping("/selVideoLook")
    private JsonData selVideoLook(){
        int videoLook=syTeacherSystemService.selVideoLook();
        return videoLook!=0? JsonData.buildSuccess(videoLook): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——收藏量
     * @Author : 柴秋生
     * @Date : 2021/8/2 19:09
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @RequestMapping("/selVideoCollect")
    private JsonData selVideoCollect(){
        int videoCollect=syTeacherSystemService.selVideoCollect();
        return videoCollect!=0? JsonData.buildSuccess(videoCollect): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——点赞量
     * @Author : 柴秋生
     * @Date : 2021/8/2 19:14
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @RequestMapping("/selVideoLike")
    private JsonData selVideoLike(){
        int videoLike=syTeacherSystemService.selVideoLike();
        return videoLike!=0? JsonData.buildSuccess(videoLike): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——编译课程数
     * @Author : 柴秋生
     * @Date : 2021/8/2 19:22
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @RequestMapping("/selCourseCstatus")
    private JsonData selCourseCstatus(){
        int courseCstatus=syTeacherSystemService.selCourseCstatus();
        return courseCstatus!=0? JsonData.buildSuccess(courseCstatus): JsonData.buildError("服务器端错误");
    }

    /**
     * 首页--已处理课程数
     * @Author : 柴秋生
     * @Date : 2021/9/17 9:02
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @GetMapping("/selAlreadyCourse")
    public JsonData selAlreadyCourse(){
        int selAlreadyCourse=syTeacherSystemService.selAlreadyCourse();
        return selAlreadyCourse!=0? JsonData.buildSuccess(selAlreadyCourse): JsonData.buildError("服务器端错误");
    }
    /**
     * 本月新增课程总数
     * @Author : 柴秋生
     * @Date : 2021/8/12 20:52
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @RequestMapping("/selCourseMonth")
    public JsonData selCourseMonth(){
        int selCourseMonth=syTeacherSystemService.selCourseMonth();
        return selCourseMonth!=0? JsonData.buildSuccess(selCourseMonth): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页--商品总览——课程数量（已上架）
     * @Author : 柴秋生
     * @Date : 2021/8/2 19:29
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @RequestMapping("/selCourseStatus")
    private JsonData selCourseStatus(){
        int courseStatus=syTeacherSystemService.selCourseStatus();
        return courseStatus!=0? JsonData.buildSuccess(courseStatus): JsonData.buildError("服务器端错误");
    }

    /**
     * 本月申请成功
     * @Author : 柴秋生
     * @Date : 2021/8/12 21:12
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @RequestMapping("/selSuccessfulApplication")
    public JsonData selSuccessfulApplication(){
        int selSuccessfulApplication=syTeacherSystemService.selSuccessfulApplication();
        return selSuccessfulApplication!=0? JsonData.buildSuccess(selSuccessfulApplication): JsonData.buildError("服务器端错误");
    }
    /**
     * 用户总览——今日新增用户总览量
     * @Author : 柴秋生
     * @Date : 2021/8/3 9:56
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @GetMapping("/selUserOverviewToday")
    public JsonData selUserOverviewToday(){
        int userOverviewToday=syTeacherSystemService.selUserOverviewToday();
        return userOverviewToday!=0? JsonData.buildSuccess(userOverviewToday): JsonData.buildError("服务器端错误");
    }
    /**
     * 用户总览——昨日新增用户总览量
     * @Author : 柴秋生
     * @Date : 2021/8/3 17:31
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @GetMapping("/selUserOverviewYesterday")
    public JsonData selUserOverviewYesterday(){
        int userOverviewYesterday=syTeacherSystemService.selUserOverviewYesterday();
        return userOverviewYesterday!=0? JsonData.buildSuccess(userOverviewYesterday): JsonData.buildError("服务器端错误");
    }
    /**
     * 用户总览——本月新增用户总览量
     * @Author : 柴秋生
     * @Date : 2021/8/3 19:05
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @GetMapping("/selUserOverviewMonth")
    public JsonData selUserOverviewMonth(){
        int userOverviewMonth=syTeacherSystemService.selUserOverviewMonth();
        return userOverviewMonth!=0? JsonData.buildSuccess(userOverviewMonth): JsonData.buildError("服务器端错误");
    }
    /**
     * 用户总览——全部用户
     * @Author : 柴秋生
     * @Date : 2021/8/3 19:37
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @GetMapping("/selUserOverviewCount")
    public JsonData selUserOverviewCount(){
        int userOverviewCount=syTeacherSystemService.selUserOverviewCount();
        return userOverviewCount!=0? JsonData.buildSuccess(userOverviewCount): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——上传视频总数
     * @Author : 柴秋生
     * @Date : 2021/8/2 9:58
     * @Param : []
     * @Return : int
     */
    @GetMapping("/selVideoCount")
    @ResponseBody
    public JsonData selVideoCount(){
        int videoCount=syTeacherSystemService.selVideoCount();
        return videoCount!=0? JsonData.buildSuccess(videoCount): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——商品总览——商品数量（已上架）
     * @Author : 柴秋生
     * @Date : 2021/8/2 20:21
     * @Param : []
     * @Return : int
     */
    @ResponseBody
    @GetMapping("/selProductSate")
    private JsonData selProductSate(){
        int productSate=syTeacherSystemService.selProductSate();
        return productSate!=0? JsonData.buildSuccess(productSate): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——上月新增课程总数
     * @Author : 柴秋生
     * @Date : 2021/9/14 10:30
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @GetMapping("/selCourseLastMonth")
    public JsonData selCourseLastMonth(){
        int selCourseLastMonth=syTeacherSystemService.selCourseLastMonth();
        return selCourseLastMonth!=0? JsonData.buildSuccess(selCourseLastMonth): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页——上月申请成功
     * @Author : 柴秋生
     * @Date : 2021/9/14 10:40
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @GetMapping("/selLastApplication")
    public JsonData selLastApplication(){
        int selLastApplication=syTeacherSystemService.selLastApplication();
        return selLastApplication!=0? JsonData.buildSuccess(selLastApplication): JsonData.buildError("服务器端错误");
    }
    /**
     * 首页--折线图
     * @Author : 柴秋生
     * @Date : 2021/9/14 19:36
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @ResponseBody
    @PostMapping("/selCurriculumCount")
    private JsonData selCurriculumCount(String name){
        Map<String, Object> stringObjectMap = null;
        try {
            stringObjectMap = syTeacherSystemService.selCurriculumCount(name);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return stringObjectMap!=null?JsonData.buildSuccess(stringObjectMap):JsonData.buildError("服务器错误");
    }

    /**
     * @Author : 李振海
     * @Date : 2021/9/27 14:18
     * @Param : [name]
     * @Return : si.yun.utils.JsonData
     * 商品购买量统计
     */
    @ResponseBody
    @PostMapping("/CommodityPurchaseStatistics")
    private JsonData CommodityPurchaseStatistics(String name){
        Map<String, Object> stringObjectMap = null;
        try {
            stringObjectMap = syTeacherSystemService.selCurriculumCount(name);
            Map <String,Object> m=syTeacherSystemService.getCountCommodity();
            stringObjectMap.putAll(m);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return stringObjectMap!=null?JsonData.buildSuccess(stringObjectMap):JsonData.buildError("服务器错误");
    }

    /**
     * @Author : 李振海
     * @Date : 2021/9/27 14:18
     * @Param : [name]
     * @Return : si.yun.utils.JsonData
     * 视频购买量统计
     */
    @ResponseBody
    @PostMapping("/CoursePurchaseStatistics")
    private JsonData CoursePurchaseStatistics(String name){
        Map<String, Object> stringObjectMap = null;
        try {
            stringObjectMap = syTeacherSystemService.selCurriculumCount(name);
            Map <String,Object> m=syTeacherSystemService.CoursePurchaseStatistics1();
            stringObjectMap.putAll(m);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return stringObjectMap!=null?JsonData.buildSuccess(stringObjectMap):JsonData.buildError("服务器错误");
    }
}
